/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_MODELS_LOGS_HPP
#define	_CUBEFS_API_MODELS_LOGS_HPP

#include <cubefs/api/reflection/value.hpp>
#include <cubefs/api/reflection/id.hpp>

namespace cubefs    {
namespace api       {

struct CUBEFS_API LogHandler: public Typed {

    enum {TRACE = 1000, DEBUG = 2000, INFO = 3000, WARN = 4000, ERROR = 5000, FATAL = 6000};

    virtual void begin(Int level)       = 0;

    virtual void log(bool value)        = 0;
    virtual void log(Byte value)        = 0;
    virtual void log(UByte value)       = 0;
    virtual void log(Short value)       = 0;
    virtual void log(UShort value)      = 0;
    virtual void log(Int value)         = 0;
    virtual void log(UInt value)        = 0;
    virtual void log(BigInt value)      = 0;
    virtual void log(float value)       = 0;
    virtual void log(double value)      = 0;
    virtual void log(IDValue value)     = 0;
    virtual void log(StringRef value)   = 0;
    virtual void log(const char* value) = 0;
    virtual void log(const void* value) = 0;

    virtual void end()                  = 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(LogHandler,    "cubefs::api::models::LogHandler");


struct CUBEFS_API DefaultLogHandler: public LogHandler {
    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(DefaultLogHandler,    "cubefs::api::models::DefaultLogHandler");

CUBEFS_API DefaultLogHandler* GetDefaultLogHandler();


struct CUBEFS_API Logger: public Typed {

    virtual Int GetLogLevel() const 						= 0;
    virtual void SetLogLevel(Int level) 					= 0;

    virtual LogHandler* GetLogHandler() const 				= 0;
    virtual void SetLogHandler(LogHandler* handler) 		= 0;
    
    virtual void begin(Int level) 							= 0;
    virtual void end()										= 0;

    virtual void log(bool value)							= 0;
    virtual void log(Byte value)							= 0;
    virtual void log(UByte value)							= 0;
    virtual void log(Short value)							= 0;
    virtual void log(UShort value)							= 0;
    virtual void log(Int value)								= 0;
    virtual void log(UInt value)							= 0;
    virtual void log(Long value)							= 0;
    virtual void log(BigInt value)							= 0;
    virtual void log(float value)							= 0;
    virtual void log(double value)							= 0;
    virtual void log(IDValue value)							= 0;
    virtual void log(StringRef value)						= 0;
    virtual void log(const char* value)						= 0;
    virtual void log(const void* value) 					= 0;
    virtual void log(size_t value)							= 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(Logger,    "cubefs::api::models::Logger");

}
}

#endif
